      COMPLEX*16 FUNCTION CEXIWD(Z1,Z2,DEPW,RHOW,GRHOW,
     1                          ALPHA1,ALPHA2)
C
C     THIS FUNCTION EVALUATES THE INTEGRAL OF THE PRODUCT OF THE
C     DERIVATIVES OF TWO BASIC DEPTH FUNCTIONS OVER THE INTERVAL 
C     Z1 TO Z2 IN THE WATER, WEIGHTED BY AN EXPONENTIAL DENSITY 
C     PROFILE.
C
      IMPLICIT REAL*8 (A-H,O-Z)
C
      COMPLEX*16 ALPHA1,ALPHA2
      COMPLEX*16 CFAC,CGRHOW,CI
      COMPLEX*16 U,V,W,X
      COMMON /BLKEVN/ HB,CW,CB,FKW,FKB,ROHW,ROHB,ATEN
C
      CI=DCMPLX(0.0D0,1.0D0)
      CGRHOW=DCMPLX(GRHOW,0.0D0)
C
C     THE FOLLOWING INCLUDES A FACTOR OF 1/FKB**2 TO MAKE THE 
C     INTEGRAL NONDIMENSIONAL
C
      CFAC=FKB**2/(4.0D0*RHOW)
C
      CEXIWD=DCMPLX(0.0D0,0.0D0)
C
      W=CI*(ALPHA1+ALPHA2)-CGRHOW
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(ALPHA1+ALPHA2)*Z2-CGRHOW*(Z2-DEPW))
      V=CDEXP(CI*(ALPHA1+ALPHA2)*Z1-CGRHOW*(Z1-DEPW))
      CEXIWD=CEXIWD+(U-V)/W
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      CEXIWD=CEXIWD+X*(Z2-Z1)
      END IF
C
      W=CI*(ALPHA1-ALPHA2)-CGRHOW
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(ALPHA1-ALPHA2)*Z2-CGRHOW*(Z2-DEPW))
      V=CDEXP(CI*(ALPHA1-ALPHA2)*Z1-CGRHOW*(Z1-DEPW))
      CEXIWD=CEXIWD+(U-V)/W
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      CEXIWD=CEXIWD+X*(Z2-Z1)
      END IF
C
      W=CI*(ALPHA2-ALPHA1)-CGRHOW
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(CI*(ALPHA2-ALPHA1)*Z2-CGRHOW*(Z2-DEPW))
      V=CDEXP(CI*(ALPHA2-ALPHA1)*Z1-CGRHOW*(Z1-DEPW))
      CEXIWD=CEXIWD+(U-V)/W
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      CEXIWD=CEXIWD+X*(Z2-Z1)
      END IF
C
      W=-CI*(ALPHA1+ALPHA2)-CGRHOW
      IF(CDABS(W) .GT. 1.0D-12) THEN
      U=CDEXP(-CI*(ALPHA1+ALPHA2)*Z2-CGRHOW*(Z2-DEPW))
      V=CDEXP(-CI*(ALPHA1+ALPHA2)*Z1-CGRHOW*(Z1-DEPW))
      CEXIWD=CEXIWD+(U-V)/W
      ELSE 
      X=CDEXP(CGRHOW*DEPW)
      CEXIWD=CEXIWD+X*(Z2-Z1)
      END IF
C
      CEXIWD=CFAC*CEXIWD
      RETURN
      END
